package cn.tedu.micro.service.business.service.impl;
import cn.tedu.micro.service.business.service.BusinessService;

import org.springframework.stereotype.Service;

@Service
public class BusinessServiceIpl01 {
//    @Autowired
//    private FeignOrderClient orderClient;
//
//    //添加@GlobalTransactional注解，标记为分布式事务的起点
//    //最终的效果就是由当前方法引发的所有远程调用对数据库的操作，要么都成功，要么都失败
//    @GlobalTransactional
//    @Override
//    public void buy() {
//        //模拟购买业务
//        //创建订单对象
////        OrderAddParam orderAddParam = new OrderAddParam();
////        orderAddParam.setProductCode("PU100");
////        orderAddParam.setUserId("UU100");
////        orderAddParam.setCount(5);
////        orderAddParam.setTotalMoney(500);
////        orderAddParam.setOrderSn("20250418");
//        //调用order
//       // orderClient.addOrder(orderAddParam);
//        orderClient.addOrder("PU100","UU100",500,5,"20250420");
//        //为了验证分布式事务效果，随机抛出异常
//        if(Math.random()<0.6){
//            System.out.println(1/0);
//        }
//    }
}
